<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

use app\admin\logic\Log as LogicLog;

/**
 * 记录行为日志
 */
function action_log($name = '', $describe = '')
{

    $logLogic = get_sington_object('logLogic', LogicLog::class);
    
    $logLogic->logAdd($name, $describe);
}

/**
 * 清除登录 session
 */
function clear_login_session()
{
    
    session('member_info',      null);
    session('member_auth',      null);
    session('member_auth_sign', null);
}

function curl($url, $data = false, $header = false)
    {
        if (!function_exists('curl_init')) {
            die('curl函数库未开启！！！');
        }
        $ch = curl_init();  //初始化一个curl
        curl_setopt($ch, CURLOPT_URL, $url);     //设置接口地址
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   //将curl_exec以文档流的形式返回而不是直接输出

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);    //关闭验证.没什么可验的.
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        if ($data) { //如果有post
            curl_setopt($ch, CURLOPT_POST, true);      //使用post方式提交
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//提交的参数 post fields
        }

        if ($header) {   //如果有header
            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        }

        $data = curl_exec($ch);    //执行curl

        if (curl_errno($ch)) {
            $debug = 'curl_errno:' . curl_errno($ch) . '<br />\n';
            $debug .= 'curl_error:' . curl_error($ch);
            die($debug);
        }
        curl_close($ch);  //关闭curl
        return $data;
    }